package com.leon.domain.auth;

/**
 * token类
 */
public class AuthToken {

    private static final long EXPIRE_INTERVAL = 180L;

    private String token;

    private long createTime;

    private long expireInterval = EXPIRE_INTERVAL;

    public AuthToken(String token, long createTime) {
        this.token = token;
        this.createTime = createTime;
    }

    /**
     * todo
     *
     * @param pwd
     * @param originUrl
     * @param timestamp
     * @param appId
     * @return
     */
    public static AuthToken generateToken(String pwd, String originUrl, long timestamp, String appId) {
        return new AuthToken("ahjscashuia", System.currentTimeMillis());
    }


    public String getToken() {
        return token;
    }

    public boolean isExpire() {
        return (createTime + expireInterval) > System.currentTimeMillis();
    }

    public boolean match(AuthToken token) {
        return this.token.equals(token.getToken());
    }
}
